package com.sloth.controller;

import com.sloth.service.ReviewService;
import com.sloth.util.ServerResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.servlet.ModelAndView;

@Controller
public class ReviewController {
    @Autowired
    private ReviewService reviewService;

    @GetMapping("review/{proId}")
    public ModelAndView getById(@PathVariable("proId") Integer proId) {

        ServerResponse serverResponse = reviewService.getById(proId);
        ModelAndView mav = new ModelAndView();
        mav.addObject("serverResponse", serverResponse);

        // 3. 跳转到响应页面
        mav.setViewName("test/serverResponse");
        return mav;

    }
}
